/*     */ package dm.jdbc.driver;
/*     */ 
/*     */ import dm.jdbc.dbaccess.Const;
/*     */ import dm.jdbc.dbaccess.DBError;
/*     */ import java.net.InetAddress;
/*     */ import java.sql.Connection;
/*     */ import java.sql.DriverPropertyInfo;
/*     */ import java.sql.SQLException;
/*     */ import java.util.Properties;
/*     */ import java.util.ResourceBundle;
/*     */ import java.util.StringTokenizer;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public class DmDriver_bs
/*     */ {
/*  40 */   private final ResourceBundle res = Const.res;
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public Connection connect(String url, Properties info)
/*     */     throws SQLException
/*     */   {
/*  73 */     Properties props = null;
/*     */     
/*  75 */     if ((url == null) || (!url.toLowerCase().startsWith("jdbc:dm:"))) {
/*  76 */       return null;
/*     */     }
/*     */     
/*  79 */     if ((props = parseURL(url, info)) == null) {
/*  80 */       DBError.throwSQLException(20018);
/*     */     }
/*  82 */     String host = props.getProperty("host", "localhost");
/*     */     
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*  94 */     String port = props.getProperty("port", 
/*  95 */       String.valueOf(5236));
/*  96 */     String database = props.getProperty("dbname", "");
/*  97 */     String user = props.getProperty("user", "SYSDBA");
/*  98 */     String passwd = props.getProperty("password", "");
/*     */     
/* 100 */     DmdbConnection_bs conn = new DmdbConnection_bs(url, 
/* 101 */       host, port, user, passwd, database, props);
/* 102 */     return conn;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public boolean acceptsURL(String url)
/*     */     throws SQLException
/*     */   {
/* 117 */     return parseURL(url, null) != null;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public DriverPropertyInfo[] getPropertyInfo(String url, Properties info)
/*     */     throws SQLException
/*     */   {
/* 143 */     info = parseURL(url, info);
/*     */     
/* 145 */     DriverPropertyInfo hostProp = new DriverPropertyInfo("host", 
/* 146 */       info.getProperty("host"));
/* 147 */     hostProp.required = true;
/* 148 */     hostProp.description = this.res.getString("description.host");
/*     */     
/* 150 */     DriverPropertyInfo portProp = new DriverPropertyInfo("port", 
/* 151 */       info.getProperty("port", String.valueOf(5236)));
/* 152 */     portProp.required = false;
/* 153 */     portProp.description = this.res.getString("desciption.port");
/*     */     
/* 155 */     DriverPropertyInfo dbProp = new DriverPropertyInfo("dbname", 
/* 156 */       info.getProperty("dbname"));
/* 157 */     dbProp.required = false;
/* 158 */     dbProp.description = this.res.getString("desciption.dbname");
/*     */     
/* 160 */     DriverPropertyInfo userProp = new DriverPropertyInfo("user", 
/* 161 */       info.getProperty("user"));
/* 162 */     userProp.required = true;
/* 163 */     userProp.description = this.res.getString("desciption.user");
/*     */     
/* 165 */     DriverPropertyInfo passwordProp = new DriverPropertyInfo("password", 
/* 166 */       info.getProperty("password"));
/* 167 */     passwordProp.required = true;
/* 168 */     passwordProp.description = this.res.getString("desciption.pwd");
/*     */     
/* 170 */     DriverPropertyInfo socketTimeout = new DriverPropertyInfo(
/* 171 */       "socketTimeout", info.getProperty("socketTimeout", "0"));
/* 172 */     socketTimeout.required = false;
/* 173 */     socketTimeout.description = this.res.getString("desciption.time.socket");
/*     */     
/* 175 */     DriverPropertyInfo continueBatchOnError = new DriverPropertyInfo(
/* 176 */       "continueBatchOnError", info.getProperty(
/* 177 */       "continueBatchOnError", "false"));
/* 178 */     continueBatchOnError.required = false;
/* 179 */     continueBatchOnError.description = this.res
/* 180 */       .getString("desciption.execute.continue");
/*     */     
/* 182 */     DriverPropertyInfo escapeProcess = new DriverPropertyInfo(
/* 183 */       "escapeProcess", info.getProperty("escapeProcess", "true"));
/* 184 */     escapeProcess.required = false;
/* 185 */     escapeProcess.description = this.res.getString("desciption.esscape.process");
/*     */     
/* 187 */     DriverPropertyInfo autoCommit = new DriverPropertyInfo("autoCommit", 
/* 188 */       info.getProperty("autoCommit", "true"));
/* 189 */     autoCommit.required = false;
/* 190 */     autoCommit.description = this.res.getString("desciption.commit.auto");
/*     */     
/* 192 */     DriverPropertyInfo maxRows = new DriverPropertyInfo("maxRows", 
/* 193 */       info.getProperty("maxRows", "0"));
/* 194 */     maxRows.required = false;
/* 195 */     maxRows.description = this.res.getString("desciption.rows.max");
/*     */     
/* 197 */     DriverPropertyInfo RowPrefetch = new DriverPropertyInfo("rowPrefetch", 
/* 198 */       info.getProperty("rowPrefetch", "10"));
/* 199 */     RowPrefetch.required = false;
/* 200 */     RowPrefetch.description = this.res.getString("desciption.fetch.rowNum");
/*     */     
/* 202 */     DriverPropertyInfo LobMode = new DriverPropertyInfo("LobMode", 
/* 203 */       info.getProperty("LobMode", "1"));
/* 204 */     LobMode.required = false;
/* 205 */     LobMode.description = this.res.getString("desciption.lob.mode");
/*     */     
/* 207 */     DriverPropertyInfo StmtPoolSize = new DriverPropertyInfo(
/* 208 */       "StmtPoolSize", info.getProperty("StmtPoolSize", "0"));
/* 209 */     StmtPoolSize.required = false;
/* 210 */     StmtPoolSize.description = this.res.getString("desciption.stmtPool.size");
/*     */     
/* 212 */     DriverPropertyInfo ignoreCase = new DriverPropertyInfo("ignoreCase", 
/* 213 */       info.getProperty("ignoreCase", "true"));
/* 214 */     ignoreCase.required = false;
/* 215 */     ignoreCase.description = this.res.getString("description.ignoreCase");
/*     */     
/* 217 */     DriverPropertyInfo comOra = new DriverPropertyInfo("comOra", 
/* 218 */       info.getProperty("comOra", "false"));
/* 219 */     comOra.required = false;
/* 220 */     comOra.description = this.res.getString("description.comOra");
/*     */     
/* 222 */     DriverPropertyInfo infoLevel = new DriverPropertyInfo("infoLevel", 
/* 223 */       info.getProperty("infoLevel", "1"));
/* 224 */     infoLevel.required = false;
/* 225 */     infoLevel.description = this.res.getString("description.infoLevel");
/*     */     
/* 227 */     DriverPropertyInfo alwayseAllowCommit = new DriverPropertyInfo(
/* 228 */       "alwayseAllowCommit", info.getProperty("alwayseAllowCommit", 
/* 229 */       "true"));
/* 230 */     alwayseAllowCommit.required = false;
/* 231 */     alwayseAllowCommit.description = "Allow commit even if autocommit is true";
/*     */     
/* 233 */     DriverPropertyInfo batchType = new DriverPropertyInfo("batchType", 
/* 234 */       info.getProperty("batchType", "1"));
/* 235 */     batchType.required = false;
/* 236 */     batchType.description = this.res.getString("description.batchType");
/*     */     
/* 238 */     DriverPropertyInfo maxCachedPstmtSize = new DriverPropertyInfo(
/* 239 */       "maxCachedPstmtSize", info.getProperty("maxCachedPstmtSize", 
/* 240 */       "0"));
/* 241 */     maxCachedPstmtSize.required = false;
/* 242 */     maxCachedPstmtSize.description = "";
/*     */     
/* 244 */     DriverPropertyInfo maxCachedResultSet = new DriverPropertyInfo(
/* 245 */       "maxCachedResultSet", info.getProperty("maxCachedResultSet", 
/* 246 */       "0"));
/* 247 */     maxCachedResultSet.required = false;
/* 248 */     maxCachedResultSet.description = "";
/*     */     
/* 250 */     DriverPropertyInfo traceLevel = new DriverPropertyInfo("traceLevel", 
/* 251 */       info.getProperty("traceLevel", "0"));
/* 252 */     traceLevel.required = false;
/* 253 */     traceLevel.description = this.res.getString("description.traceLevel");
/*     */     
/* 255 */     DriverPropertyInfo appName = new DriverPropertyInfo("appName", 
/* 256 */       info.getProperty("appName", ""));
/* 257 */     appName.required = false;
/* 258 */     appName.description = this.res.getString("description.appName");
/*     */     
/* 260 */     DriverPropertyInfo sessionTimeout = new DriverPropertyInfo(
/* 261 */       "sessionTimeout", info.getProperty("sessionTimeout", "0"));
/* 262 */     sessionTimeout.required = false;
/* 263 */     sessionTimeout.description = "0";
/*     */     
/* 265 */     DriverPropertyInfo isCompress = new DriverPropertyInfo("isCompress", 
/* 266 */       info.getProperty("isCompress", "false"));
/* 267 */     isCompress.required = false;
/* 268 */     isCompress.description = "0";
/*     */     
/* 270 */     DriverPropertyInfo sslFilesPath = new DriverPropertyInfo(
/* 271 */       "sslFilesPath", info.getProperty("sslFilesPath", ""));
/* 272 */     sslFilesPath.required = false;
/* 273 */     sslFilesPath.description = "";
/*     */     
/* 275 */     DriverPropertyInfo sslKeystorePass = new DriverPropertyInfo(
/* 276 */       "sslKeystorePass", info.getProperty("sslKeystorePass", ""));
/* 277 */     sslFilesPath.required = false;
/* 278 */     sslFilesPath.description = "";
/*     */     
/* 280 */     DriverPropertyInfo resultSetType = new DriverPropertyInfo(
/* 281 */       "resultSetType", info.getProperty("resultSetType", "1003"));
/* 282 */     sslFilesPath.required = false;
/* 283 */     sslFilesPath.description = "";
/*     */     
/* 285 */     DriverPropertyInfo kerberosLoginConfPath = new DriverPropertyInfo(
/* 286 */       "kerberosLoginConfPath", 
/* 287 */       info.getProperty("kerberosLoginConfPath"));
/* 288 */     kerberosLoginConfPath.required = false;
/* 289 */     kerberosLoginConfPath.description = "";
/*     */     
/* 291 */     DriverPropertyInfo mppLocal = new DriverPropertyInfo("mppLocal", 
/* 292 */       info.getProperty("mppLocal"));
/* 293 */     kerberosLoginConfPath.required = false;
/* 294 */     kerberosLoginConfPath.description = "";
/*     */     
/* 296 */     DriverPropertyInfo rwSeparate = new DriverPropertyInfo("rwSeparate", 
/* 297 */       info.getProperty("rwSeparate"));
/* 298 */     kerberosLoginConfPath.required = false;
/* 299 */     kerberosLoginConfPath.description = "";
/*     */     
/* 301 */     DriverPropertyInfo rwPercent = new DriverPropertyInfo("rwPercent", 
/* 302 */       info.getProperty("rwPercent"));
/* 303 */     kerberosLoginConfPath.required = false;
/* 304 */     kerberosLoginConfPath.description = "";
/*     */     
/* 306 */     DriverPropertyInfo dbmdChkPrv = new DriverPropertyInfo("dbmdChkPrv", 
/* 307 */       info.getProperty("dbmdChkPrv"));
/* 308 */     kerberosLoginConfPath.required = false;
/* 309 */     kerberosLoginConfPath.description = "Whether the privilege should be checked when getting database metadata information,false in default";
/*     */     
/*     */ 
/* 312 */     DriverPropertyInfo uKeyName = new DriverPropertyInfo("uKeyName", 
/* 313 */       info.getProperty("uKeyName"));
/* 314 */     uKeyName.required = false;
/* 315 */     uKeyName.description = "";
/*     */     
/* 317 */     DriverPropertyInfo uKeyPin = new DriverPropertyInfo("uKeyPin", 
/* 318 */       info.getProperty("uKeyPin"));
/* 319 */     uKeyPin.required = false;
/* 320 */     uKeyPin.description = "";
/*     */     
/* 322 */     DriverPropertyInfo[] dpi = { hostProp, portProp, dbProp, 
/* 323 */       continueBatchOnError, maxRows, autoCommit, RowPrefetch, 
/* 324 */       LobMode, StmtPoolSize, ignoreCase, comOra, infoLevel, 
/* 325 */       alwayseAllowCommit, batchType, maxCachedPstmtSize, 
/* 326 */       maxCachedResultSet, traceLevel, appName, sessionTimeout, 
/* 327 */       isCompress, sslFilesPath, sslKeystorePass, resultSetType, 
/* 328 */       kerberosLoginConfPath, mppLocal, rwSeparate, rwPercent, 
/* 329 */       dbmdChkPrv, uKeyName, uKeyPin };
/*     */     
/* 331 */     return dpi;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public int getMajorVersion()
/*     */   {
/* 341 */     int pointIndex = "7.1.4.74".indexOf(".");
/* 342 */     String ver = "7";
/* 343 */     if (pointIndex != -1) {
/* 344 */       ver = "7.1.4.74".substring(0, pointIndex);
/*     */     }
/* 346 */     return Integer.parseInt(ver);
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public int getMinorVersion()
/*     */   {
/* 355 */     String fulVersion = "7.1.4.74";
/* 356 */     int pointIndex1 = fulVersion.indexOf(".");
/* 357 */     int pointIndex2 = -1;
/*     */     
/* 359 */     if (pointIndex1 != -1) {
/* 360 */       pointIndex2 = fulVersion.indexOf(".", pointIndex1 + 1);
/*     */     }
/* 362 */     String ver = "0";
/* 363 */     if ((pointIndex1 != -1) && (pointIndex2 != -1)) {
/* 364 */       ver = fulVersion.substring(pointIndex1 + 1, pointIndex2);
/*     */     }
/* 366 */     return Integer.parseInt(ver);
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public boolean jdbcCompliant()
/*     */   {
/* 390 */     return true;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public Properties parseURL(String url, Properties defaults)
/*     */   {
/* 410 */     Properties urlProps = new Properties(defaults);
/*     */     
/* 412 */     if (url == null) {
/* 413 */       return null;
/*     */     }
/*     */     
/*     */ 
/*     */ 
/*     */ 
/* 419 */     int index = url.indexOf("?");
/*     */     
/* 421 */     if (index != -1) {
/* 422 */       String paramString = url.substring(index + 1, url.length());
/* 423 */       url = url.substring(0, index);
/*     */       
/* 425 */       StringTokenizer queryParams = new StringTokenizer(paramString, 
/* 426 */         "&");
/*     */       
/* 428 */       while (queryParams.hasMoreTokens()) {
/* 429 */         StringTokenizer vp = new StringTokenizer(
/* 430 */           queryParams.nextToken(), "=");
/* 431 */         String param = "";
/*     */         
/* 433 */         if (vp.hasMoreTokens()) {
/* 434 */           param = vp.nextToken();
/*     */         }
/*     */         
/* 437 */         String value = "";
/*     */         
/* 439 */         if (vp.hasMoreTokens()) {
/* 440 */           value = vp.nextToken();
/*     */         }
/*     */         
/* 443 */         if ((value.length() > 0) && (param.length() > 0)) {
/* 444 */           urlProps.put(param.trim(), value.trim());
/*     */         }
/*     */       }
/*     */     }
/*     */     
/*     */ 
/* 450 */     StringTokenizer st = new StringTokenizer(url, ":/[]", true);
/*     */     
/* 452 */     if (st.hasMoreTokens()) {
/* 453 */       String protocol = st.nextToken();
/*     */       
/* 455 */       if (protocol != null) {
/* 456 */         if (!protocol.equalsIgnoreCase("jdbc")) {
/* 457 */           return null;
/*     */         }
/*     */       } else {
/* 460 */         return null;
/*     */       }
/*     */     } else {
/* 463 */       return null;
/*     */     }
/*     */     
/*     */ 
/* 467 */     if (st.hasMoreTokens()) {
/* 468 */       String colon = st.nextToken();
/*     */       
/* 470 */       if (colon != null) {
/* 471 */         if (!colon.equals(":")) {
/* 472 */           return null;
/*     */         }
/*     */       } else {
/* 475 */         return null;
/*     */       }
/*     */     } else {
/* 478 */       return null;
/*     */     }
/*     */     
/*     */ 
/* 482 */     if (st.hasMoreTokens()) {
/* 483 */       String subProto = st.nextToken();
/*     */       
/* 485 */       if (subProto != null) {
/* 486 */         if (!subProto.equalsIgnoreCase("dm")) {
/* 487 */           return null;
/*     */         }
/*     */       } else {
/* 490 */         return null;
/*     */       }
/*     */     } else {
/* 493 */       return null;
/*     */     }
/*     */     
/*     */ 
/* 497 */     if (st.hasMoreTokens()) {
/* 498 */       String colon = st.nextToken();
/*     */       
/* 500 */       if (colon != null) {
/* 501 */         if (!colon.equals(":")) {
/* 502 */           return null;
/*     */         }
/*     */       } else {
/* 505 */         return null;
/*     */       }
/*     */     } else {
/* 508 */       return null;
/*     */     }
/*     */     
/*     */ 
/* 512 */     if (st.hasMoreTokens()) {
/* 513 */       String slash = st.nextToken();
/* 514 */       String slash2 = "";
/*     */       
/* 516 */       if (st.hasMoreTokens()) {
/* 517 */         slash2 = st.nextToken();
/*     */       }
/*     */       
/* 520 */       if ((slash != null) && (slash2 != null)) {
/* 521 */         if ((!slash.equals("/")) || (!slash2.equals("/"))) {
/* 522 */           return null;
/*     */         }
/*     */       } else {
/* 525 */         return null;
/*     */       }
/*     */     } else {
/* 528 */       return null;
/*     */     }
/*     */     
/*     */ 
/* 532 */     if (st.hasMoreTokens()) {
/* 533 */       String token = st.nextToken();
/*     */       
/* 535 */       if (token != null)
/*     */       {
/* 537 */         if (token.equals("[")) {
/* 538 */           int begin = url.indexOf("[");
/* 539 */           int end = url.indexOf("]");
/* 540 */           String ipv6 = url.substring(begin + 1, end);
/*     */           try
/*     */           {
/* 543 */             InetAddress inetAddress = 
/* 544 */               InetAddress.getByName(ipv6);
/* 545 */             ipv6 = inetAddress.getHostAddress();
/*     */             
/* 547 */             urlProps.put("host", ipv6.trim());
/*     */             
/* 549 */             while (st.hasMoreTokens()) {
/* 550 */               token = st.nextToken();
/* 551 */               if (token.equals("]")) {
/*     */                 break;
/*     */               }
/*     */             }
/* 555 */             if (st.hasMoreTokens()) {
/* 556 */               token = st.nextToken();
/*     */               break label600; }
/* 558 */             return urlProps;
/*     */ 
/*     */           }
/*     */           catch (Exception e)
/*     */           {
/* 563 */             e.printStackTrace();
/*     */           }
/*     */           
/*     */ 
/*     */         }
/* 568 */         else if ((!token.equals(":")) && (!token.equals("/")))
/*     */         {
/* 570 */           urlProps.put("host", token.trim());
/*     */           
/* 572 */           if (st.hasMoreTokens()) {
/* 573 */             token = st.nextToken();
/*     */           } else {
/* 575 */             return urlProps;
/*     */           }
/*     */         }
/*     */         
/*     */         label600:
/*     */         
/* 581 */         if ((token.equals(":")) && 
/* 582 */           (st.hasMoreTokens())) {
/* 583 */           token = st.nextToken();
/* 584 */           urlProps.put("port", token.trim());
/*     */           
/* 586 */           if (st.hasMoreTokens()) {
/* 587 */             token = st.nextToken();
/*     */           }
/*     */         }
/*     */       }
/*     */       else
/*     */       {
/* 593 */         return null;
/*     */       }
/*     */     }
/*     */     
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/* 601 */     return urlProps;
/*     */   }
/*     */ }


/* Location:              D:\Program Files\DBMS_20150813\jdbc\Dm7JdbcDriver17.jar!\dm\jdbc\driver\DmDriver_bs.class
 * Java compiler version: 2 (46.0)
 * JD-Core Version:       0.7.1
 */